package insight.jsp.custom.taglib;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

public class FormTagHandler extends TagSupport {
	private static final long serialVersionUID = 1L;
	private String id;
	private String title;
	private String style;

	@Override
	public int doStartTag() throws JspException {
		try {
			JspWriter out = pageContext.getOut();
			String startTag = "<div class=\"easyui-panel formBody\"\n"
					+ "   data-options=\"headerCls:'formHeader',bodyCls:'formBody'\"\n"
					+ "   title=\"" + (title != null ? title : "") + "\""
					+ (style != null ? style : "") + ">\n" + "\t<form id=\""
					+ id + "\" method=\"post\">";
			out.println(startTag);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return EVAL_BODY_INCLUDE;
	}

	@Override
	public int doEndTag() throws JspException {
		try {
			JspWriter out = pageContext.getOut();
			out.println("\t</form>\n</div>");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return EVAL_PAGE;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getStyle() {
		return style;
	}

	public void setStyle(String style) {
		this.style = style;
	};
}